import bottomBar from "./components/bottom_bar.vue"
export default {
  data() {
    return {
      content: '<h2>哈哈哈</h2>',
      type: 1,
      order_id: "",
      myLocation: "",
      detailData: {},
      info: false
    };
  },
  activated() {
    this.type = this.$route.params.type * 1;
    this.order_id = this.$route.params.order_id;
    this.myLocation = JSON.parse(localStorage.getItem("myLocation"))
    this.fun.setWXTitle(this.type == 1 ? '个人需求' : '企业需求');
    if(this.type == 1) {
      this.getData()
    }else {
      this.getEnterpriseNeed();
    }
  },
  methods: {
    // 个人需求
    getData() {
      let form = this.type == 1 ? { nid: this.order_id } : ""
      $http.get("plugin.be-within-call.frontend.index.need", { 
        lng: this.myLocation ? this.myLocation.point.lng : "",
        lat: this.myLocation ? this.myLocation.point.lat : "",
        ...form,
      }).then(({ data , result , msg }) => {
        console.log(data , result , msg,22222222);
        if (result) {
          this.detailData = data;
        } else {
          this.$toast(msg);
        }
        this.info = true;
      });
    },
    // 企业需求详情
    getEnterpriseNeed() {
      $http.get("plugin.be-within-call.frontend.index.enterprise-need", { nid : this.order_id}).then(({ data , result , msg }) => {
        console.log(data , result , msg,22222222);
        if (result) {
          this.detailData = data;
        } else {
          this.$toast(msg);
        }
        this.info = true;
      });
    },
    // 跳转企业信息
    goEnterpriseInformation() {
      this.$router.push(
        this.fun.getUrl("anyTerpriseInformation", {id: this.detailData.has_one_enterprise.id})
      );
    }
  },
  components: { bottomBar }
};
